# 1. 基本算术运算加、减、乘、除、取整除、取余、幂运算
a = 10
b = 3
print("a + b =", a + b)
print("a - b =", a - b)
print("a * b =", a * b)
print("a / b =", a / b)  # 浮点除，和java不同
print("a // b =", a // b)  # 整除，取整
print("a % b =", a % b)  # 获取余数，求模
print("a ** 3 =", a ** 3)  # 幂运算

# 2. 赋值运算
a = 2
print(a)
a += 2  # 自增
# 没有类似java的i++、++i这种语法
print(a)
a = a + 2
print(a)

# 3. 比较运算符
print("3 != 3", 3 != 3)  # 判断不相等
print("3 == 2", 3 == 2)  # 判断相等
print("3 > 2", 3 >= 2)
print("3 < 3", 3 <= 3)
print("浮点数和整数判断", 3.0 == 3)
print("布尔值判断", True == False)
print("字符串的比较", 'hello' < 'hell')  # 字符串的比较运算：每个字符的ascii码值
print(1 < 2 < 3)
print(1 < 2 and 2 < 3)
print('y' < 'x' == False)
print('y' < 'x' and 'x' == False)

# 4. 逻辑运算符
# 和java不同，使用and、or、not类似java的&&、||、!
# 与，并且 and
print(True and False)
print(True and True)
print(True and False and True)
print(1 == 1 and True and 2 < 3)
print('hello' and 'hi')  # 短路运算
print('' and 'hi')
print(False and 'hi')
print(0 and 1)
# 或者or
print(True or False)
print(False or False or True)
print(1 or 0)
print(2024 or 2025 or 0)
print(0 or '' or 888)
# 非not
print(not True)
print(not 1)
print(not '')
# 优先级 not>and>or
print(True and False and not False)
print(True or False and True or False)

# 5. 位运算符
# 按位与&
'''
101
111
----
101
'''
print(5 & 7)
# 按位或 |
'''
011
100
----
111
'''
print(3 | 4)

# 按位异或
'''
010
100
----
110
'''
print(2 ^ 4)
# 按位取反~
'''
01
---
10
110
'''
print(~1)
# 左移 右移
'''
101
----
10100
'''
print(5 << 2)
